using UnityEngine;
using System.Collections;

public class AddTimeScaleEffect : CharacterAction
{
	public AnimationCurve curve;
	public float length = 2.0f;
	private float enterTime;
	
	public override void OnActionEnter(Character character)
	{
		base.OnActionEnter(character);
		enterTime = Time.time;
	}
	
	public override void OnActionExit(Character character)
	{
		base.OnActionExit(character);
		Time.timeScale = 1.0f;
	}
	
	public override void OnFrameUpdate (Character.FrameUpdate arg)
	{
		float time = (Time.time - enterTime)/length;
        //Debug.LogError(time);
		if(time >= 1.0f){
			Time.timeScale = 1.0f;
			return;
		}
		Time.timeScale = curve.Evaluate(time);

	}
}
